package org.mtree.context.wrapper;

import java.util.Collection;

import org.mtree.context.Context;

/**
 * 封装并发上下文
 * 
 * @author rushman
 * @date 2017-11-04
 */
public class ConcurrentContextWrapper implements Context {

    private final Context context;

    public ConcurrentContextWrapper(Context context) {
        super();
        this.context = context;
    }

    @Override
    public Object get(String name) {
        synchronized (context) {
            return context.get(name);
        }
    }

    @Override
    public Object set(String name, Object value) {
        synchronized (context) {
            return context.set(name, value);
        }
    }

    @Override
    public Object remove(String name) {
        synchronized (context) {
            return context.remove(name);
        }
    }

    @Override
    public boolean has(String name) {
        synchronized (context) {
            return context.has(name);
        }
    }

    @Override
    public Collection<String> nameSet() {
        return context.nameSet();
    }

}
